/************************************************************************
*
*    File Name: map.cpp
*    Description: 编写地图类
*    Version: V1.0
*    Author: 王涵
*    Create Time: 2024-11-27
*
*************************************************************************/
#include "map.h"

Map::Map (QObject *parent) : QObject(parent) ,QGraphicsPixmapItem ()
{

    background_1_y = -GAME_HEIGHT;
    background_2_y = 0;
    background_speed = MAP_SCROLL_SPEED;
}



void Map::set_pos(){
    if(background_item_1 != nullptr)    background_item_1->setPos(0, background_1_y);
    if(background_item_2 != nullptr)    background_item_2->setPos(0, background_2_y);
}

void Map::set_item(QGraphicsPixmapItem *background_item_1,QGraphicsPixmapItem *background_item_2){
    this->background_item_1 = background_item_1;
    this->background_item_2 = background_item_2;
}

void Map::picture_choose(int path)
{
    // 选择皮肤
    switch (path){
    case 1:
        background_1.load(MAP_PATH_1);
        background_2.load(MAP_PATH_1);
        break;
    case 2:
        background_1.load(MAP_PATH_2);
        background_2.load(MAP_PATH_2);
        break;
    case 3:
        background_1.load(MAP_PATH_3);
        background_2.load(MAP_PATH_3);
    }
    background_1 = background_1.scaled(GAME_WIDTH,GAME_HEIGHT);
    background_2 = background_2.scaled(GAME_WIDTH,GAME_HEIGHT);
}

Map::~Map()
{

}
